const express = require("express");
const getSendData = require("../utils/getSendData");
const blogtypeServ = require("../services/blogtypeService");

const router = express.Router();

router.post("/", async (req, res, next) => {
    res.send(getSendData(await blogtypeServ.addBlogtype(req.body)));
});

router.get("/", async (req, res, next) => {
    res.send(getSendData(await blogtypeServ.getBlogtypes()));
});

router.get("/:id", async (req, res, next) => {
    res.send(getSendData(await blogtypeServ.getBlogtypeById(req.params.id)));
});

router.put("/:id", async (req, res, next) => {
    res.send(getSendData(await blogtypeServ.updateBlogtype(req.params.id, req.body)));
});

router.delete("/:id", async (req, res, next) => {
    res.send(getSendData(await blogtypeServ.deleteBlogtype(req.params.id)));
});


module.exports = router;
